package com.xiangjun.proxytest.jdkdynamicproxytest.impl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKDynamicProxyFactory implements InvocationHandler {

    //需要被代理的对象
    private Object object;

    public JDKDynamicProxyFactory(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        Object result = null;
        System.out.printf("\n调用前加密\n");
        result = method.invoke(object,args);
        System.out.printf("\n调用后解密\n");
        return result;
    }
}
